package org.demo.db.meta;

import java.util.ArrayList;
import java.util.List;

/**
 * database table info
 * @author  
 * @date    2010-9-3
 * @file    org.demo.db.meta.Table.java
 */
public class Table {
	private String schema;
	private String name;
	private String remarks;
	private String tableType;
	private List<Field> fields = new ArrayList<Field>();
	private List<Constraint> primaryKeys = new ArrayList<Constraint>();
	private List<Constraint> foreignKeys = new ArrayList<Constraint>();
	private List<Index> indexes = new ArrayList<Index>();
	
	public String getSchema() {
		return schema;
	}
	public void setSchema(String schema) {
		this.schema = schema;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getRemarks() {
		return remarks;
	}
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	public String getTableType() {
		return tableType;
	}
	public void setTableType(String tableType) {
		this.tableType = tableType;
	}
	public List<Field> getFields() {
		return fields;
	}
	public void setFields(List<Field> fields) {
		this.fields = fields;
	}
	public List<Constraint> getPrimaryKeys() {
		return primaryKeys;
	}
	public void setPrimaryKeys(List<Constraint> primaryKeys) {
		this.primaryKeys = primaryKeys;
	}
	public List<Constraint> getForeignKeys() {
		return foreignKeys;
	}
	public void setForeignKeys(List<Constraint> foreignKeys) {
		this.foreignKeys = foreignKeys;
	}
	public List<Index> getIndexes() {
		return indexes;
	}
	public void setIndexes(List<Index> indexes) {
		this.indexes = indexes;
	}
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("  Table [name=" + name);
		sb.append(", remarks=" + remarks + "\n");
		for(int i=0; i<fields.size(); i++){
			sb.append("    " + fields.get(i)).append('\n');
		}
		sb.append("  ]");
		return sb.toString();
	}
}
